#ifndef ROOM_ASSISTANT_COMMAND_IN_H_
#define ROOM_ASSISTANT_COMMAND_IN_H_
#include "command.h"

#pragma pack(1)
namespace Cmd
{
        namespace RoomAssistant
        {
                //  cmd declaration
                enum {
                        CMDIN_LOGIN             = 0x0016,       // 登录RoomRecordServer验证指令
                        CMDIN_ROOM              = 0x0017,	// 与RoomServer交互的指令
                };
                enum { //CMDIN_LOGIN
                        SCMDIN_LOGIN                            = 0x0001,       // 请求登录RoomRecordServer
                        SCMDIN_LOGIN_RESPONCE                   = 0x0002,	// 登录RoomRecordServer返回
                };
                enum { //CMDIN_ROOM
                        SCMDIN_AUTO_GHOST_ADD_REQ               = 0x0000,       // room->assistant: 请求增加自动马甲
                        SCMDIN_AUTO_GHOST_ADD_RES               = 0x0001,       // assistant->room: 请求增加自动马甲 返回
                        SCMDIN_AUTO_GHOST_DEL_REQ               = 0x0002,       // room->assistant: 请求回收自动马甲
                        SCMDIN_ROOM_CONFIG_CHANGE_NOTIFY        = 0x0003,       // assistant->room: 通知房间配置变化 
                        SCMDIN_AUTO_GHOST_RESTORE_REQ           = 0x0004,
                        SCMDIN_AUTO_GHOST_RESTORE_RES           = 0x0005,
                };

                //	cmd definition
                struct stLoginCmd
                        :t_NullCmd
                {
                        public:
                                stLoginCmd()
                                        : t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN)
                                {
                                        dest_type_ = ROOMASSISTANTSERVER;
                                        server_type_ = 0;
                                        server_id_ = 0;
                                }
                                void setDestType(const WORD &dt)
                                {
                                        dest_type_ = dt;
                                }
                                void setServerType(const WORD &st)
                                {
                                        server_type_ = st;
                                }
                                void setServerID(const DWORD &id)
                                {
                                        server_id_ = id;
                                }
                                WORD getDestType() const 
                                {
                                        return dest_type_;
                                }
                                WORD getServerType() const
                                {
                                        return server_type_;
                                }
                                DWORD getServerID() const
                                {
                                        return server_id_;
                                }
                        private:
                                WORD dest_type_;
                                WORD server_type_;
                                DWORD server_id_;
                };
                struct stLoginResponce
                        :t_NullCmd
                {
                        stLoginResponce()
                                : t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN_RESPONCE)
                        {
                        }
                };

                //      cmd room
                struct stRoomCmdBase:
                        t_NullCmd
                {
                        public:
                                stRoomCmdBase(WORD subcmd)
                                        : t_NullCmd(CMDIN_ROOM, subcmd)
                                {
                                        room_id_ = 0;
                                }
                                void setRoomID(const DWORD &rid)
                                {
                                        room_id_ = rid;
                                }
                                DWORD getRoomID() const
                                {
                                        return room_id_;
                                }
                        private:
                                DWORD room_id_;
                };
                struct stAutoGhostAddReq:
                        stRoomCmdBase
                {
                        public:
                                stAutoGhostAddReq()
                                        : stRoomCmdBase(SCMDIN_AUTO_GHOST_ADD_REQ)
                                {
                                        room_id_ = 0;
                                        req_num_ = 0;
                                }
                                void setRoomID(const DWORD &rid)
                                {
                                        room_id_ = rid;
                                }
                                void setReqNum(const WORD &rnum)
                                {
                                        req_num_ = rnum;
                                }
                                DWORD getRoomID() const
                                {
                                        return room_id_;
                                }
                                WORD  getReqNum() const
                                {
                                        return req_num_;
                                }
                        private:
                                DWORD room_id_;
                                WORD  req_num_;
                };
                struct stAutoGhostAddRes:
                        stRoomCmdBase
                {
                        public:
                                stAutoGhostAddRes()
                                        : stRoomCmdBase(SCMDIN_AUTO_GHOST_ADD_RES)
                                {
                                        room_id_ = 0;
                                        ghost_num_ = 0;
                                }
                                struct stGhostInfo{   
                                        DWORD id; 
                                        char username[MAX_ACCOUNT_SIZE + 1]; 
                                        char nickname[MAX_NAME_SIZE + 1]; 
                                };
                                void setRoomID(const DWORD &rid)
                                {
                                        room_id_ = rid;
                                }
                                void setGhostNum(const WORD &n)
                                {
                                        ghost_num_ = n;
                                }
                                void incGhostNum()
                                {
                                        ghost_num_++;
                                }
                                DWORD getRoomID() const
                                {
                                        return room_id_;
                                }
                                WORD getGhostNum() const
                                {
                                        return ghost_num_;
                                }
                                DWORD getSize()
                                {
                                        return sizeof(*this) + ghost_num_*sizeof(list_[0]);
                                }
                                void addElement(const DWORD &id, const std::string &name, const std::string &nick)
                                {
                                        list_[ghost_num_].id = id;
                                        strncpy(list_[ghost_num_].username, name.c_str(), MAX_ACCOUNT_SIZE);
                                        strncpy(list_[ghost_num_].nickname, nick.c_str(), MAX_NAME_SIZE);
                                        ghost_num_++;
                                }
                                stGhostInfo &getElement(const WORD &n)
                                {
                                        return list_[n];
                                }
                        private:
                                DWORD room_id_;
                                WORD ghost_num_;
                                stGhostInfo list_[0];
                };
                struct stAutoGhostDelReq:
                        stRoomCmdBase
                {
                        public:
                                stAutoGhostDelReq()
                                        : stRoomCmdBase(SCMDIN_AUTO_GHOST_DEL_REQ)
                                {
                                        ghost_num_ = 0;
                                }
                                DWORD getSize()
                                {
                                        return sizeof(*this) + ghost_num_ * sizeof(ghost_[0]);
                                }
                                void setGhostNum(const WORD &n)
                                {
                                        ghost_num_ = n;
                                }
                                void incGhostNum(void)
                                {
                                        ghost_num_++;
                                }
                                WORD getGhostNum() const
                                {
                                        return ghost_num_;
                                }
                                void addElement(const DWORD &id)
                                {
                                        ghost_[ghost_num_] = id;
                                        ghost_num_++;
                                }
                                DWORD &getElement(const WORD &n)
                                {
                                        return ghost_[n];
                                }

                        private:
                                WORD ghost_num_;
                                DWORD ghost_[0];
                };
                struct stRoomConfigChangeNotify:
                        stRoomCmdBase
                {
                        public:
                                stRoomConfigChangeNotify()
                                        : stRoomCmdBase(SCMDIN_ROOM_CONFIG_CHANGE_NOTIFY)
                                {
                                        size_ = 0;
                                }
                                WORD size_;
                                struct {
                                        DWORD roomid;
                                        WORD action;
                                } list_[0];
                                DWORD getSize() {
                                        return sizeof(*this)+size_*sizeof(list_[0]);
                                }
                };
                struct stAutoGhostRestoreReq:
                        stRoomCmdBase
                {
                        public:
                                stAutoGhostRestoreReq()
                                        : stRoomCmdBase(SCMDIN_AUTO_GHOST_RESTORE_REQ)
                                {
                                        room_id_ = 0;
                                }
                                void setRoomID(const DWORD &rid)
                                {
                                        room_id_ = rid;
                                }
                                DWORD getRoomID() const
                                {
                                        return room_id_;
                                }
                        private:
                                DWORD room_id_;
                };
                struct stAutoGhostRestoreRes:
                        stRoomCmdBase
                {
                        public:
                                stAutoGhostRestoreRes()
                                        : stRoomCmdBase(SCMDIN_AUTO_GHOST_RESTORE_RES)
                                {
                                        room_id_ = 0;
                                        ghost_num_ = 0;
                                }
                                struct stGhostInfo{   
                                        DWORD id; 
                                        char username[MAX_ACCOUNT_SIZE + 1]; 
                                        char nickname[MAX_NAME_SIZE + 1]; 
                                };
                                void setRoomID(const DWORD &rid)
                                {
                                        room_id_ = rid;
                                }
                                void setGhostNum(const WORD &n)
                                {
                                        ghost_num_ = n;
                                }
                                void incGhostNum()
                                {
                                        ghost_num_++;
                                }
                                DWORD getRoomID() const
                                {
                                        return room_id_;
                                }
                                WORD getGhostNum() const
                                {
                                        return ghost_num_;
                                }
                                DWORD getSize()
                                {
                                        return sizeof(*this) + ghost_num_*sizeof(list_[0]);
                                }
                                void addElement(const DWORD &id, const std::string &name, const std::string &nick)
                                {
                                        list_[ghost_num_].id = id;
                                        strncpy(list_[ghost_num_].username, name.c_str(), MAX_ACCOUNT_SIZE);
                                        strncpy(list_[ghost_num_].nickname, nick.c_str(), MAX_NAME_SIZE);
                                        ghost_num_++;
                                }
                                stGhostInfo &getElement(const WORD &n)
                                {
                                        return list_[n];
                                }
                        private:
                                DWORD room_id_;
                                WORD ghost_num_;
                                stGhostInfo list_[0];
                };
        }; //namespace RoomCache
}; //namespace Cmd
#pragma pack() //pack(1)

#endif //ROOM_ASSISTANT_COMMAND_IN_H_
